package ar.org.cfired.creditos.abm;

import java.util.ArrayList;
import java.util.HashMap;

import org.hibernate.Session;

public class Destinatario extends Entidad{

	private int des_id;
	private int obs_id;
	private String obs_usuario;
	
	
	
	public void setDesId (int des_id) {
		this.des_id = des_id;
	}
	public int getDesId() {
		return (this.des_id);
	}

	public void setObsId (int obs_id) {
		this.obs_id = obs_id;
	}
	public int getObsId() {
		return (this.obs_id);
	}

	public void setObsUsuario (String obs_usuario) {
		if (obs_usuario != null)
			this.obs_usuario = obs_usuario.substring(0, Math.min(200, obs_usuario.length()));
		else
			this.obs_usuario = new String();
	}
	public String getObsUsuario() {
		return (this.obs_usuario);
	}
	
	@Override
	public void setVariables(HashMap<String, Object> variables) {
		if (variables.containsKey("obs_usuario"))
			this.setObsUsuario(String.valueOf(variables.get("obs_usuario")));
	}
	
	@Override
	public String getCriterioBusqueda2() {
		String busqueda = " from Destinatario ";
		boolean filtro = false;
		//ArrayList a = new ArrayList();
		if(this.getDesId() > 0){
			if(!filtro){
				busqueda += " where " + " des_id = " + this.getDesId();
			filtro = true;
			}
			else
				busqueda += " and " + " des_id = " + this.getDesId();
		}
		if(this.getDesId() > 0){
			if(!filtro){
				busqueda += " where " + "obs_id = " + this.getObsId();
			filtro = true;
			}
			else
				busqueda += " and " + "obs_id = " + this.getObsId();
		}
		if(this.getObsUsuario() != null){
			if(!filtro){
				busqueda +=  " where " + "obs_usuario = '" + this.getObsUsuario()+ "' ";
			filtro = true;
			}
			else
				busqueda +=  " and " + "obs_usuario = '" + this.getObsUsuario()+ "' ";
		}	
	
		return  busqueda;
		}
		/*
			if(this.)
				busqueda += "from Destinatario ";
						if(!filtro){
							busqueda += " where " + " des_id = " + arrDestinatario.get(i).getDesId();
						filtro = true;
						}
						else
							busqueda += " and " + " des_id = " + arrDestinatario.get(i).getDesId();
					}
					if(arrDestinatario.get(i).getObsId() > 0){
						if(!filtro){
							busqueda += " where " + "obs_id = " + arrDestinatario.get(i).getObsId();
						filtro = true;
						}
						else
							busqueda += " and " + "obs_id = " + arrDestinatario.get(i).getObsId();
					}
					if(!arrDestinatario.get(i).getObsUsuario().equals("")){
						if(!filtro){
							busqueda +=  " where " + "obs_usuario = '" + arrDestinatario.get(i).getObsUsuario()+ "' ";
						filtro = true;
						}
						else
							busqueda +=  " and " + "obs_usuario = '" + arrDestinatario.get(i).getObsUsuario()+ "' ";
					}
					
					busqueda =  busqueda;
					
			}
			this.BUSQUEDA = busqueda;
		}
		return busqueda;
	}*/
		
}
